package run.bottle.app.repository;

import org.springframework.lang.NonNull;
import run.bottle.app.model.entity.SysUser;
import run.bottle.app.repository.base.BaseRepository;

import java.util.Optional;

/**
 * User repository.
 *
 * @author Lycheng
 */
public interface UserRepository extends BaseRepository<SysUser, Integer> {

    /**
     * 通过用户名获取用户
     *
     * @param username username must not be blank
     * @return an optional user
     */
    @NonNull
    Optional<SysUser> findByUsername(@NonNull String username);

    /**
     * 通过电子邮件获取用户
     *
     * @param email email must not be blank
     * @return an optional user
     */
    @NonNull
    Optional<SysUser> findByEmail(@NonNull String email);

}
